|
ARD2
1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
|
00001 00018 #ifndef _MMA68XX_DIAG_H 00019 #define _MMA68XX_DIAG_H 00020 00021 /* 00022 ************************************************************** 00023 * Defines, Macros and Typedefs 00024 **************************************************************/ 00025 /*** Constant Macros ***/ 00026 /* Default Yes and No defines */ 00027 #ifndef TRUE 00028 #define TRUE (1u) 00029 #endif 00030 #ifndef CLEAR 00031 #define CLEAR (0u) 00032 #endif 00033 #ifndef BITS_IN_NIBBLE 00034 #define BITS_IN_NIBBLE (4u) 00035 #endif 00036 #ifndef BITS_IN_BYTE 00037 #define BITS_IN_BYTE (8u) 00038 #endif 00039 #ifndef BYTES_IN_16 00040 #define BYTES_IN_16 (2u) 00041 #endif 00042 #ifndef BYTES_IN_32 00043 #define BYTES_IN_32 (4u) 00044 #endif 00045 #ifndef BIT_DEFINITION 00046 #define BIT_DEFINITION 00047 #define BIT0 (1u << 0u) 00048 #define BIT1 (1u << 1u) 00049 #define BIT2 (1u << 2u) 00050 #define BIT3 (1u << 3u) 00051 #define BIT4 (1u << 4u) 00052 #define BIT5 (1u << 5u) 00053 #define BIT6 (1u << 6u) 00054 #define BIT7 (1u << 7u) 00055 #define BIT8 (1u << 8u) 00056 #define BIT9 (1u << 9u) 00057 #define BIT10 (1u << 10) 00058 #define BIT11 (1u << 11) 00059 #define BIT12 (1u << 12) 00060 #define BIT13 (1u << 13) 00061 #define BIT14 (1u << 14) 00062 #define BIT15 (1u << 15) 00063 #define BIT16 (1u << 16) 00064 #define BIT17 (1u << 17) 00065 #define BIT18 (1u << 18) 00066 #define BIT19 (1u << 19) 00067 #define BIT20 (1u << 20) 00068 #define BIT21 (1u << 21) 00069 #define BIT22 (1u << 22) 00070 #define BIT23 (1u << 23) 00071 #define BIT24 (1u << 24) 00072 #define BIT25 (1u << 25) 00073 #define BIT26 (1u << 26) 00074 #define BIT27 (1u << 27) 00075 #define BIT28 (1u << 28) 00076 #define BIT29 (1u << 29) 00077 #define BIT30 (1u << 30) 00078 #define BIT31 (1u << 31) 00079 #endif 00080 00081 #define RAW_ACCEL_MODE 7u 00082 #define OC_ACCEL_MODE 3u 00083 00084 /* Limits for CA tests */ 00085 #define CA_TEST_SAMPLES_AMOUNT 256u 00086 #define CA_TEST_RAW_LIMIT_LO 1988u 00087 #define CA_TEST_RAW_LIMIT_HI 2108u 00088 #define CA_TEST_RAW_LIMIT_HYST 5u 00089 #define CA_TEST_OC_LIMIT_LO 2047u /*-1LSB as Russ suggested instead of -0.25LSB in the spec*/ 00090 #define CA_TEST_OC_LIMIT_HI 2049u /*+1LSB as Russ suggested instead of +0.25LSB in the spec*/ 00091 #define CA_TEST_SELF_LIMIT_LO 442u 00092 #define CA_TEST_SELF_LIMIT_HI 663u 00093 #define CA_TEST_SELF_RAW_VS_OC_LIMIT 5u 00094 #define CA_TEST_SELF_CROSS_AXIS_LIMIT 10u 00095 00096 /* Errors for tests */ 00097 #ifndef STATUS_CA_FAILED 00098 #define STATUS_CA_FAILED (BIT27 | BIT26) 00099 #endif 00100 #define STATUS_CA_RAW_X_FAILED 0x00000001 00101 #define STATUS_CA_RAW_Y_FAILED 0x00000002 00102 #define STATUS_CA_RAW_SELF_X_FAILED 0x00000004 00103 #define STATUS_CA_RAW_SELF_Y_FAILED 0x00000008 00104 #define STATUS_CA_RAW_HYST_X_FAILED 0x00000010 00105 #define STATUS_CA_RAW_HYST_Y_FAILED 0x00000020 00106 #define STATUS_CA_OC_X_FAILED 0x00000040 00107 #define STATUS_CA_OC_Y_FAILED 0x00000080 00108 #define STATUS_CA_OC_SELF_X_FAILED 0x00000100 00109 #define STATUS_CA_OC_SELF_Y_FAILED 0x00000200 00110 #define STATUS_CA_OC_HYST_X_FAILED 0x00000400 00111 #define STATUS_CA_OC_HYST_Y_FAILED 0x00000800 00112 00113 /*** Function Macros ***/ 00114 #ifndef N_ELEMENTS 00115 #define N_ELEMENTS(X) (sizeof(X)/sizeof(*(X))) 00116 #endif 00117 00118 extern const uint16_t cau16MMA6800TestSettingsRaw[]; 00119 extern const uint16_t cau16MMA6800TestSettingsRawSelfX[]; 00120 extern const uint16_t cau16MMA6800TestSettingsRawSelfY[]; 00121 extern const uint16_t cau16MMA6800TestSettingsOC[]; 00122 extern const uint16_t cau16MMA6800TestSettingsOCSelfX[]; 00123 extern const uint16_t cau16MMA6800TestSettingsOCSelfY[]; 00124 extern const uint32_t cau32MMA6800ErrorCodeX[]; 00125 extern const uint32_t cau32MMA6800ErrorCodeY[]; 00126 extern const uint8_t cu8SizeofTestSettings; 00127 extern const uint8_t cu8SizeofTestAmount; 00128 00129 /* 00130 ****************************************************************************** 00131 * 00132 * Function: u32fnMMA6800ReadAccelSum() 00133 * 00134 */ 00150 uint32_t u32fnMMA6800ReadAccelSum(const uint8_t u8Axis, 00151 const uint8_t u8AccelMode, 00152 uint32_t* pu32Destination, 00153 const uint8_t cu8Accel); 00154 /* 00155 ****************************************************************************** 00156 * 00157 * Function: u32fnMMA6800ConfigTest() 00158 * 00159 */ 00175 uint32_t u32fnMMA6800ConfigTest(uint32_t* pu32Destination, 00176 const uint16_t* pu16DataToSend, 00177 const uint8_t u8Size, 00178 const uint8_t u8AccelMode, 00179 const uint8_t u8Axis, 00180 const uint8_t cu8Accel); 00181 /* 00182 ****************************************************************************** 00183 * 00184 * Function: u32fnMMA6800PreSelfTest() 00185 * 00186 */ 00206 uint32_t u32fnMMA6800PreSelfTest(uint32_t* pu32Destination, 00207 const uint16_t* pu16DataToSend, 00208 const uint8_t u8Size, 00209 const uint8_t cu8AccelMode, 00210 const uint8_t cu8Axis, 00211 const uint16_t cu16LowLimit, 00212 const uint16_t cu16HighLimit, 00213 const uint32_t cu32StatusErrCode, 00214 const uint8_t cu8Accel); 00215 /* 00216 ****************************************************************************** 00217 * 00218 * Function: u32fnMMA6800PowerOnSelfTest() 00219 * 00220 */ 00241 uint32_t u32fnMMA6800PowerOnSelfTest(uint32_t* pu32Destination, 00242 const uint16_t* pu16DataToSend, 00243 const uint16_t* pu16DataToSendCross, 00244 const uint8_t u8Size, 00245 const uint8_t cu8AccelMode, 00246 const uint8_t cu8Axis, 00247 const uint32_t cu32StatusErrCode, 00248 const uint8_t cu8Accel); 00249 /* 00250 ****************************************************************************** 00251 * 00252 * Function: u32fnMMA6800PostSelfTest() 00253 * 00254 */ 00272 uint32_t u32fnMMA6800PostSelfTest(uint32_t* pu32Destination, 00273 const uint16_t* pu16DataToSend, 00274 const uint8_t u8Size, 00275 const uint8_t cu8AccelMode, 00276 const uint8_t cu8Axis, 00277 const uint32_t cu32StatusErrCode, 00278 const uint8_t cu8Accel); 00279 00280 #endif /* _FILENAME_H */